<?php
class ThanhPhan extends AppModel{
	public $name = "ThanhPhan";
	
	public $hasMany = array(
		'ThanhPhanTthc' => array(
            'className'  => 'ThanhPhanTthc',
        )
	);
	
	public function getListThanhPhanGiayToByTthcId($tthcId) {
		$db = $this->getDataSource();
		
		$sql = "SELECT * FROM thanh_phans ThanhPhan where id in (select thanh_phan_id from thanh_phan_tthcs WHERE tthc_id = ?)";
		
		return $db->fetchAll($sql, array($tthcId));
	}
	
	public function getListThanhPhanHosoByHosoId($hosoId) {
		$db = $this->getDataSource();
		
		$sql = "SELECT * FROM thanh_phans ThanhPhan where id in (select thanh_phan_id from thanh_phan_tthcs WHERE tthc_id = ?)";
		
		return $db->fetchAll($sql, array($tthcId));
	}
}

